using System;

namespace RxHeat.Tracing
{
    /// <summary>
    ///     The Default RxHeat trace listener. It internally uses the Framework <see cref="System.Diagnostics.Trace" /> object
    /// </summary>
    public class DefaultRxHeatTraceListner : IRxHeatTraceListner
    {
        private readonly string _tracerName;

        internal DefaultRxHeatTraceListner(string tracerName)
        {
            _tracerName = tracerName;
        }

        /// <summary>
        ///     Writes error information
        /// </summary>
        /// <param name="exception">The exception.</param>
        /// <param name="traceDetails">The trace info.</param>
        public void Error(Exception exception, TraceDetails traceDetails)
        {
            System.Diagnostics.Trace.TraceError("ERROR {2}, {0}, Exception {1}", traceDetails, exception.ToString(),
                                                _tracerName);
        }

        /// <summary>
        ///     Writes trace information
        /// </summary>
        /// <param name="traceDetails">The trace info.</param>
        public void Trace(TraceDetails traceDetails)
        {
            System.Diagnostics.Trace.TraceInformation("TRACE {0}, {1}", traceDetails, _tracerName);
        }
    }
}